<?php

namespace app\admin\controller\auth;

use think\Request;
use app\admin\service\auth\AdminService;
use app\admin\controller\Base;

class Admin extends Base
{
    public function userinfo(Request $request)
    {
        $token = getHeaderToken();
        $userInfo = getJWT($token);
        $service = new AdminService();
        return $service->Info($userInfo);
    }
    public function list(Request $request)
    {
        $param = $request->param();
        $service = new AdminService();
        return $service->getList($param);
    }
    public function add(Request $request)
    {
        $param = $request->param();
        $service = new AdminService();
        return $service->Add($param);
    }
    public function edit(Request $request)
    {
      $data = $request->param();
      $service = new AdminService();
      $id = $data['id'];
      unset($data['id']);
      return $service->Edit($id, $data);
    }
    public function del(Request $request)
    {
        $data = $request->param();
        $ids = is_array($data['ids']) ? $data['ids'] : explode(',', $data['ids']);
        $service = new AdminService();
        return $service->Delete($ids);
    }
    public function log(Request $request)
    {
        $param = $request->param();
        $Service = new AdminService();
        $data = $Service->getLog($param);
        return $data;
    }
    public function logdel(Request $request)
    {
        $param = $request->param();
        $ids = is_array($param['ids']) ? $param['ids'] : explode(',', $param['ids']);
        $Service = new AdminService();
        $data = $Service->DeleteLog($ids);
        return $data;
    }

}

